<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>商品套餐管理</title>
	<meta name="decorator" content="default"/>
	<style type="text/css">
	.BoxDiv{
			position:fixed;
			width:300px;
			height:326px;
			background:#f5f5f5;
			top:10%;
			left:25%;
			margin:0 auto;
			border:1px solid #CCC;
			box-shadow:3px 3px 10px 4px #DDD;
		}
	#showGoodsCombDiv{
		position:fixed;
		padding:10px 15px;
		width:800px;
		height:300px;
		background:#FFF;
		top:10%;
		left:15%;
		margin:0 auto;
		border:1px solid #CCC;
		box-shadow:3px 3px 10px 4px #DDD;
	}
	</style>
	<script type="text/javascript">
		$(document).ready(function() {
			
		});
		function page(n,s){
			$("#pageNo").val(n);
			$("#pageSize").val(s);
			$("#searchForm").submit();
        	return false;
        }
		function showImgDiv(url){
			$("#showImg").attr("src",url);
			$("#showImgDiv").show();
		}
		function closeImgDiv(){
			$("#showImg").attr("src","");
			$("#showImgDiv").hide();
		}
		function showGoodsComboDetail(id){
			$.ajax({
				url:'${ctx}/sys/goodsCombo/selectGoodsComDetail',
				data:{'goodsCombId':id},
				async:false,
				success:function(result){
					if(result!=null){
						var html = '';
						$(result).each(function(e,v){
							html+='<tr><td>'+v.goodsName+'</td>';
							html+='<td>'+v.partsCode+'</td>';
							html+='<td>'+v.price+'</td>';
							html+='<td>'+v.num+'</td></tr>';
						})
						$('#showGoodsCombDiv tbody').html(html);
					}
				}
			})
			$('#showGoodsCombDiv').show();
		}
		function closeShowGoodsCombDiv(){
			$('#showGoodsCombDiv').hide();
		}
		function deleteGoodsCombo(id){
			$.ajax({
				url:'${ctx}/sys/goodsCombo/couldDelete',
				data:{'goodsComboId':id},
				async:false,
				success:function(result){
					if('couldDelete'==result){
						confirmx('确定删除该套餐信息','${ctx}/sys/goodsCombo/delete?id='+id);
					}else{
						showTip("不可删除", "", 3000, 0);
						return false;
					}
				}
			})
		}
	</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<li class="active"><a href="${ctx}/sys/goodsCombo/">商品套餐列表</a></li>
		<shiro:hasPermission name="sys:goodsCombo:edit"><li><a href="${ctx}/sys/goodsCombo/form">商品套餐添加</a></li></shiro:hasPermission>
	</ul>
	<form:form id="searchForm" modelAttribute="goodsCombo" action="${ctx}/sys/goodsCombo/" method="post" class="breadcrumb form-search">
		<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
		<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
		<ul class="ul-form">
			<li><label>套餐名称：</label>
				<form:input path="name" htmlEscape="false" maxlength="50" class="input-medium"/>
			</li>
			<li class="btns"><input id="btnSubmit" class="btn btn-primary" type="submit" value="查询"/></li>
			<li class="clearfix"></li>
		</ul>
	</form:form>
	<div style="display:none">
		<sys:message content="${message}"/>
	</div>
	<table id="contentTable" class="table table-striped table-bordered table-condensed">
		<thead>
			<tr>
				<th>序号</th>
				<th>套餐名称</th>
				<th>套餐图片</th>
				<th>套餐商品</th>
				<th>套餐价</th>
				<shiro:hasPermission name="sys:goodsCombo:edit"><th>操作</th></shiro:hasPermission>
			</tr>
		</thead>
		<tbody>
		<c:forEach items="${page.list}" var="goodsCombo" varStatus="index">
			<tr>
				<td>${index.index+1 }</td>
				<td>${goodsCombo.name}</td>
				<td><a href="javascript:;" onclick="showImgDiv('${goodsCombo.photo}')">查看</a></td>
				<td><a href="javascript:;" onclick="showGoodsComboDetail('${goodsCombo.id}')">查看套餐</a></td>
				<td>${goodsCombo.price}</td>
				<shiro:hasPermission name="sys:goodsCombo:edit"><td>
    				<a href="${ctx}/sys/goodsCombo/edit?id=${goodsCombo.id}">编辑</a>
					<a onclick="deleteGoodsCombo(${goodsCombo.id})">删除</a>
				</td></shiro:hasPermission>
			</tr>
		</c:forEach>
		</tbody>
	</table>
	<div class="pagination">${page}</div>
	<div style="display:none;" class="BoxDiv" id="showImgDiv">
		<img id="showImg" src="" style="width:300px;height:300px;">
		<div style="border-top:1px;">
			<input type="button" style="width: 300px;" value="关闭" onclick="closeImgDiv()">
		</div>
	</div>
	<div style="display:none;overflow: scroll;" id="showGoodsCombDiv">
		<input class="btn btn-primary" type="button" value="返回" onclick="closeShowGoodsCombDiv()"/>
		<table id="contentTable1" class="table table-striped table-bordered table-condensed">
			<thead>
				<tr>
					<th>商品名称</th>
					<th>配件编号</th>
					<th>售价</th>
					<th>商品数量</th>
				</tr>
			</thead>
			<tbody>
			</tbody>
		</table>
	</div>
</body>
</html>